{extend name='base'/}
{block name='title'}修改资料{/block}
{block name='main'}
<link rel="stylesheet" href="__CSS__/booklist.css">
<style>
    .main {
        background: url("__IMG__/list_bg.jpg") left top repeat-y;
    }
    .user-form {
        width: 60%;
    }
    .user-form label{
        font-size: 14px;
    }
</style>
<div class="row m-0 mt-3 main">
    {include file='user/user_left'}
    <div class="right flex-1">
        <form class="user-form mb-3">
            <div class="form-group">
                <label for="password">新登录密码</label>
                <input type="password"  name="data[password]" class="form-control" id="password" value="" placeholder="不填写，则不做修改">
            </div>
            <div class="form-group">
                <label for="rpassword">重复登录密码</label>
                <input type="password"  name="data[rpassword]" class="form-control" id="rpassword" value="" placeholder="">
            </div>
            <div class="form-group">
                <label for="payword">新支付密码</label>
                <input type="password"  name="data[payword]" class="form-control" id="payword" value="" placeholder="不填写，则不做修改">
            </div>
            <div class="form-group">
                <label for="rpayword">重复支付密码</label>
                <input type="password"  name="data[rpayword]" class="form-control" id="rpayword" value="" placeholder="">
            </div>
            <button type="button" class="btn btn-primary edituser-btn">立即修改</button>
        </form>
    </div>
</div>
{/block}

{block name='js'}
<script>
    $(function () {
        let lock = false;
        $(".edituser-btn").on('click', function () {
           if (lock) {
               return false;
           }
           lock = true;
           $.post("{:url('User/password')}", $(".user-form").serialize(), function (res) {
               if (res.code == 0) {
                   swal("提示", res.msg, {
                       icon : "error",
                       buttons: {
                           confirm: {
                               className : 'btn btn-danger',
                               text : '确定',
                           }
                       },
                   });
               }else{
                   swal("提示", res.msg, {
                       icon : "success",
                       buttons: {
                           confirm: {
                               className : 'btn btn-success',
                               text : '确定',
                           }
                       }
                   }).then(function () {
                       window.location.replace("{:url('User/index')}");
                   });
               }
               lock = false;
           }, 'json');
        });
    });
</script>
{/block}